package smoothcraft.Util.mute;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class Main implements CommandExecutor {
	private static API api = new API();
	private static smoothcraft.API message = new smoothcraft.API();
	@SuppressWarnings("deprecation")
	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] arg) {
		if(cmd.getName().equals("shield")) {
			if(api.containsPlayer(sender.getName())) {
				api.remove(sender.getName());
				sender.sendMessage(message.getMessage("mute.false"));
				return true;
			}
			sender.sendMessage(message.getMessage("mute.true").replaceAll(",","\n"));
			api.joinSet(sender.getName());
			return true;
		}
		if(arg.length < 1) {
			sender.sendMessage(message.getMessage("mute.error1"));
			return true;
		}
		if(Bukkit.getOfflinePlayer(arg[0]).isOnline() == false) {
			sender.sendMessage(message.getMessage("mute.error2"));
			return true;
		}
		api.joinSet(arg[0]);
		sender.sendMessage(message.getMessage("mute.mute"));
		return false;
	}
}
